<?php
/*
 *缓存管理
 *author 王建 
 */
class CacheAction extends BaseAction{
    public $d = '';
    public $cacheDir = array();
    function __construct(){
        parent::__construct();
        $this->cacheDir = array(
        		array('name'=>'编译缓存' , 'dir'=>APP_PATH."/Runtime/Cache" , "en"=>'Cache'),
        		array('name'=>'数据缓存' , 'dir'=>APP_PATH."/Runtime/Data", "en"=>'Data'),
        		array('name'=>'日志缓存' , 'dir'=>APP_PATH."/Runtime/Logs", "en"=>'Logs'),
        		array('name'=>'临时缓存' , 'dir'=>APP_PATH."/Runtime/Temp", "en"=>'Temp'),
        );
    }
    function index(){
        $action = $this->_request("action");    
        $action_array = array("show","update_cache");
        $action = !in_array($action,$action_array)?'show':$action ;
        if($action == 'show'){
            $typeid = intval($this->_request("typeid"));
            $this->assign("cacheDir"  ,$this->cacheDir);
            $this->display();
        }elseif($action == 'update_cache'){
            $this->update_cache();
        }
    }
    public function update_cache(){
    	if(!$_POST['cache']){
    		echo result_to_towf_new(null, 0, "请选择更新缓存", null);
    		exit;
    	}
    	foreach($_POST['cache'] as $k => $v ){
    		emDeleteFile($this->cacheDir[$k]['dir']);
    	}
    	echo result_to_towf_new(null, 1, "更新缓存成功", null);
    }


}